$(document).ready(function(){
 //今日工作展示
   $("#zhan").click(function(){
    $("#bao").hide();
    $("#show").show();
    return false;
   });
   $("#kai").click(function(){
    $("#bao").hide();
    $("#show").show();
    return false;
   });
   $("#shou").click(function(){
    $("#bao").show();
    $("#show").hide();
    return false;
   });
   $("#qi").click(function(){
    $("#bao").show();
    $("#show").hide();
    return false;
   });
   
    $("#zhan1").click(function(){
            $("#td1").text("总结内容：无");
            $("#td2").html("附件：");
    var date=$("#taskDate").val();
    $.post("expe/expe_getExpeByDate.action",{"date":date},function(date){
        if(date=="]"){
           
        }else{
        var data=eval(date);
           $.each(data,function(i,v){                      
                      $.each(v,function(k,val){   
                         if(k=="content"){
                           $("#td1").text("总结内容："+val);
                         }else if(k=="path"){
                           $("#td2").append("<a href='expe/expe_doDownFile.action?fileName="+val+"'>"+val+"</a>");
                         }
                     })
           })           
        }
    });
    $("#bao1").hide();
    $("#show1").show();
    return false;
   });
   $("#kai1").click(function(){
            $("#td1").text("总结内容：无");
            $("#td2").html("附件：");
     var date=$("#taskDate").val();
    $.post("expe/expe_getExpeByDate.action",{"date":date},function(date){
        if(date=="]"){
           
        }else{
        var data=eval(date);
           $.each(data,function(i,v){                      
                      $.each(v,function(k,val){   
                         if(k=="content"){
                           $("#td1").text("总结内容："+val);
                         }else if(k=="path"){
                           $("#td2").append("<a href='expe/expe_doDownFile.action?fileName="+val+"'>"+val+"</a>");
                         }
                     })
           })           
        }
    });
    $("#bao1").hide();
    $("#show1").show();
    return false;
   });
   $("#shou1").click(function(){
    $("#bao1").show();
    $("#show1").hide();
    return false;
   });
   $("#qi1").click(function(){
    $("#bao1").show();
    $("#show1").hide();
    return false;
   });
   
   //选择复选框
    $("input[type='checkbox']").click(function(){
           var taskId=$(this).parent().attr("id");
           if($(this).attr("class")=='mynav'){
              if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
               $.post("task/task_updateTaskState.action",{"task.taskId":taskId,"task.taskState":1},function(data){
                  
               });
             }
             else{
               $(this).parent().removeClass("shanchu");
                $.post("task/task_updateTaskState.action",{"task.taskId":taskId,"task.taskState":0},function(data){
                  
               });
             }
           }
            
      });    
})
//以下是上传
 var _upload_url = baseurl+'/expe/expe_doAddFile.action';
		var _swf_url = baseurl+'/swfupload/swfupload.swf';
		var _button_url = baseurl+'/swfupload/swfupload_browse_button_trans_56x22.PNG';
		$(function(){
				fileQueued = function(file){
					var tmpId = file.id
					$("#fileList").append("<div class='parentdiv'><span style='font-size:13px'>"+file.name+"\uff08"+parseInt(file.size/1024)+"kb\uff09</span><div style='border:\'solid 1px black\''><div id='"+tmpId+"'></div></div><div style='float:right;margin-top:-20px;font-size:13px'><a  myid='"+tmpId+"' class='mydel' style='cursor:pointer'>删除</a></div></div>")
					$("#filepath").append("<span id='"+tmpId+"'>"+file.name+"</span>");
					$("a.mydel").bind("click",function(){
					var id=$(this).attr("myid");
					  $(this).parents("div.parentdiv").remove();
				      $("span[id='"+id+"']").remove();
					  return false;
					});
					var bar = $("#"+tmpId)
					var borderOfBar = bar.parent(),fileInfo = borderOfBar.prev(),fileDiv = borderOfBar.parent()
					$("#fileList").css({
						left		: '0px', 
						position	: 'relative', 
						top			: '0px', 
						'max-height': (this.customSettings.fileListHeight||100)+'px', 
						overflow	: 'auto'
					})
					fileDiv.css({
						height : '12px',
						marginBottom : '5px'
					})
					fileInfo.css({
						"float" : 'left',
						height	: $("#"+tmpId).parent().parent().height()+"px",
						marginRight : '2px',
						lineHeight : $("#"+tmpId).parent().parent().height()+"px"
					})
					bar.css({
						width	: '1px',
						'background-color' : 'green',
						height		: $("#"+tmpId).parent().parent().height()
					})
					borderOfBar.css({
						border		: 'solid 1px #8B878A',
						width		: '100px',
						marginLeft  : $("#"+tmpId).parent().prev().width()+2+"px",
						height		: $("#"+tmpId).parent().parent().height()
					})
					file.progressId = tmpId
				},
	
			fileQueueError = function(file,code,message){
				//console.log(file)
				//console.log(code)
				//console.log(message)
			}
		
			uploadStart = function(file){
				this.addPostParam("fileName", file.name)
			//	this.addPostParam("fileType", file.type)
				//console.log(file)
			}
			
			uploadProgress = function(file, complete, total){
				$("#"+file.id).css({
					width : (100*(complete/total))+"px"
				})
			}
			
			uploadError = function(file,code,message){
		//		console.log(file)
		//		console.log(code)
		//		console.log(message)
			}
			
			uploadSuccess = function(file, response){	 
				 
			}
			
			uploadComplete = function(file){
				if (this.getStats().files_queued !== 0) {
					this.startUpload()
				}
			}
			
			fileDialogComplete = function(fileNumber, queuedNumber){
				if(queuedNumber>0){
					this.startUpload()
				}
			}
			
			var upload = new SWFUpload({
					upload_url: _upload_url,
	//				post_params: this.params,
					file_post_name : 'fileData',
					file_size_limit : 100*1024*1024,	// 100MB
					file_types : "*.*",
					file_types_description : "All Files",
					file_upload_limit : "10",
					file_queue_limit : "0",
					file_queued_handler : fileQueued,
					file_queue_error_handler : fileQueueError,
					upload_start_handler : uploadStart,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete,
					file_dialog_complete_handler : fileDialogComplete,
					button_image_url : _button_url,
					button_placeholder_id : "swfupload",
					button_window_mode: 'opaque',
					button_width: 76,
					button_height: 22,
					flash_url : _swf_url,
					custom_settings : {
						hiddenName : this.hiddenName,
						fileListHeight : this.fileListHeight
					},
					debug: false
				});
				 
})
//控制每条任务nav边框的显示和隐藏
 $(document).ready(function(){
   $("div.nav").mouseover(function(){
       $(this).css("border","1px solid #CCC");
   }).mouseout(function(){
       $(this).css("border","none");
   });
 })
//拖到效果js
/*以下是四象限拖到左部*/
    var elem = '';
  $(document).ready(function(){
    $(".nav").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    { 
        elem = e.srcElement || e.target; 
    }
	});
	
$(".menu").droppable({
	accept: ".nav",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var nowText=$("#taskDate").val();
        var currentDate=new Date(new Date()-1000*60*60*24);
        var selectDate=new Date(nowText.replace(/-/g,"/"));  
        if(selectDate<currentDate){
         return false;
        }
        var taskDate=$("#taskDate").val();
        var parentId=$(this).children("div.menutitle").attr("id");
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;  
		var num=$("#"+oid).parent().attr("id"); 
		if((num==-1)||(num==-2)||(num==-3)||(num==-4)){
         
        }
        else{
         if($("#"+oid).parent().children("div.nav").length==2){  
            $("#"+oid).siblings("div.menutitle").children("img.myimg").css("visibility","hidden");
         }
        }                 
		$("#"+oid).remove();
        $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html(o).css("display","block"));
        $(this).children("div.menutitle").children("img.myimg").css("visibility","visible");
        $("#"+oid).click(function(){
    $("div.menu").children("div.nav").css("background-color","white");
    $("div.menutitle").css("background-color","white");
     $(this).css("background-color","#DCD6D6");
     $("#delid").val(oid);
     $("#input1").show();
     $("#input2").hide();
     $("#input3").show();
     $("#input4").hide();
   })
        $(this).children("div.nav").css("display","block");     
        $.post("task/task_doAjaxUpdateToMenuNav.action",{"task.taskId":oid,"task.task.taskId":parentId},function(data){
        });
         
	}
	
});
  });
  /*以上是四象限拖到左部*/
   /*以下是四象限拖到四象限标题*/
  $(document).ready(function(){
    
	
    $(".nav").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".first").droppable({
	accept: ".nav",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {
        var taskDate=$("#taskDate").val();
        var typeId=$(this).siblings("div.onelist").attr("myid");
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;      
		      
		var num=$("#"+oid).parent().attr("id"); 
		if((num==-1)||(num==-2)||(num==-3)||(num==-4)){
         
        }
        else{
         if($("#"+oid).parent().children("div.nav").length==2){  
           $("#"+oid).parent().children("div.menutitle").children("img.myimg").css("visibility","hidden");
         }
        }
        
		$("#"+oid).remove();
        $(this).siblings().append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
	    $(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	    $.post("task/task_doAjaxUpdateNavToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
	}
	
});
  });
  /*以上是四象限拖到四象标题*/
   /*以下是四象限拖到四象限标题*/
  $(document).ready(function(){
    
	
    $(".nav").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".onelist").droppable({
	accept: ".nav",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {
        var taskDate=$("#taskDate").val();
        var typeId=$(this).attr("myid");
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;      
		
		var num=$("#"+oid).parent().attr("id"); 
		if((num==-1)||(num==-2)||(num==-3)||(num==-4)){
         
        }
        else{
         if($("#"+oid).parent().children("div.nav").length==2){  
           $("#"+oid).parent().children("div.menutitle").children("img.myimg").css("visibility","hidden");
         }
        }
                
		$("#"+oid).remove();
        $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
	    $(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	    $.post("task/task_doAjaxUpdateNavToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
	}
	
});
  });
  /*以上是四象限拖到四象标题*/
   /*以下是四象限拖到左部标题*/
  $(document).ready(function(){
    
	
    $(".nav").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".leftbg").droppable({
	accept: ".nav",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {  
      var nowText=$("#taskDate").val();
        var currentDate=new Date(new Date()-1000*60*60*24);
        var selectDate=new Date(nowText.replace(/-/g,"/"));  
        if(selectDate<currentDate){
         return false;
        }
       var taskDate=$("#taskDate").val();
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       		
		var num=$("#"+oid).parent().attr("id"); 
		if((num==-1)||(num==-2)||(num==-3)||(num==-4)){
         
        }
        else{
         if($("#"+oid).parent().children("div.nav").length==2){  
           $("#"+oid).parent().children("div.menutitle").children("img.myimg").css("visibility","hidden");
         }
        }
		       
		$("#"+oid).remove();
		$("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);
        $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
	     $.post("task/task_doAjaxUpdateNavToMenuTitle.action",{"task.taskId":oid},function(data){
         
        });
	}		
});
  });
  /*以上是四象限拖到左部标题*/
  /*以下是四象限拖到左部临时区域*/
  $(document).ready(function(){   	
    $(".nav").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".temp").droppable({
	accept: ".nav",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {    var nowText=$("#taskDate").val();
        var currentDate=new Date(new Date()-1000*60*60*24);
        var selectDate=new Date(nowText.replace(/-/g,"/"));  
        if(selectDate<currentDate){
         return false;
        }
        var taskDate=$("#taskDate").val();
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;    
		
		var num=$("#"+oid).parent().attr("id"); 
		if((num==-1)||(num==-2)||(num==-3)||(num==-4)){
         
        }
        else{
         if($("#"+oid).parent().children("div.nav").length==2){  
           $("#"+oid).parent().children("div.menutitle").children("img.myimg").css("visibility","hidden");
         }
        }
		          
		$("#"+oid).remove();
		$("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);
        $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
	    $.post("task/task_doAjaxUpdateNavToMenuTitle.action",{"task.taskId":oid},function(data){
         
        });
	}
	
});
  });
  /*以上是四象限拖到左部临时区域*/
  // 以下是拖动menu 1)
     $(document).ready(function(){
    $(".menutitle").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".onelist").droppable({
	accept: ".menutitle",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
        var typeId=$(this).attr("myid");
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       
		var childlength=$("#"+oid).siblings("div.nav").length;
		if(childlength>0){
		 alert("包含子任务!");
		}
		else{ 
		$("#"+oid).parent().remove(); 
		if(o==null||o==""){return false;}
        $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
		$(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	    $.post("task/task_doAjaxUpdateMenuTitleToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
		}
		
	    
	}
	
});
  });
  // 2)
  $(document).ready(function(){
    $(".menutitle").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".first").droppable({
	accept: ".menutitle",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
        var typeId=$(this).siblings("div.onelist").attr("myid");
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       
		var childlength=$("#"+oid).siblings("div.nav").length;
		if(childlength>0){
		 alert("包含子任务!");
		}
		else{
		$("#"+oid).parents("div.menu").remove(); 
		if(o==null||o==""){return false;}
        $(this).siblings().append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
		$(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	     $.post("task/task_doAjaxUpdateMenuTitleToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
		}
	    
	}
	
});
  });
   //3)
    $(document).ready(function(){
    $(".menutitle").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".leftbg").droppable({
	accept: ".menutitle",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       
		var childlength=$("#"+oid).siblings("div.nav").length;
		if(childlength>0){
		 alert("包含子任务!");
		}
		else{ 
		$("#"+oid).parents("div.menu").remove();
		$("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);
         $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
		}
	    
	}
	
});
  });
   //4)
    $(document).ready(function(){
    $(".menutitle").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".menu").droppable({
	accept: ".menutitle",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
        var perentId=$(this).children("div.menutitle").attr("id"); 
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       
		var childlength=$("#"+oid).siblings("div.nav").length;
		if(childlength>0){
		 alert("包含子任务!");
		}
		else{
		if($(this).children("div.menutitle").attr("id")!=oid){ 
		$("#"+oid).parents("div.menu").remove(); 
		$(this).children("div.menutitle").children("img.myimg").css("visibility","visible");
        $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html(o).css("display","block"));
        $("#"+oid).click(function(){
    $("div.menu").children("div.nav").css("background-color","white");
    $("div.menutitle").css("background-color","white");
     $(this).css("background-color","#DCD6D6");
     $("#delid").val(oid);
     $("#input1").show();
     $("#input2").hide();
     $("#input3").show();
     $("#input4").hide();
   })
         $(this).children("div.nav").css("display","block");
         $.post("task/task_doAjaxUpdateMenuTitleToNav.action",{"task.taskId":oid,"task.task.taskId":perentId},function(data){
        });
		}
		else{
		}
		
		}
	    
	}
	
});
  });
  //5)
    $(document).ready(function(){
    $(".menutitle").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".temp").droppable({
	accept: ".menutitle",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {    var taskDate=$("#taskDate").val();
        var o = elem.title;
		var oid = elem.id;
		var sid = "s" + oid;       
		var childlength=$("#"+oid).siblings("div.nav").length;
		if(childlength>0){
		 alert("包含子任务!");
		}
		else{  
		$("#"+oid).parents("div.menu").remove(); 	
		$("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);
        $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
		 
		}
	    
	}
	
});
  });
  
 //6)
    $(document).ready(function(){
    $("img.myimg").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
        alert("包含子任务！");
    }
	});	
  }); 
  //span移动 1)
  $(document).ready(function(){
    $("span").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".leftbg").droppable({
	accept: "span",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val(); 
		var oid = elem.id;
		var o=elem.title;
		$myimg=$("span[id='"+oid+"']").siblings("img");
		if($myimg.css("visibility")=="visible"){
		  alert("包含子任务!");
		}
		else{ $("span[id='"+oid+"']").parents(".menutitle").parents(".menu").remove();
		   $("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);       
           $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
          
		}	    
	}
	
});
  });
  //span移动 2)
  $(document).ready(function(){
    $("span").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".temp").droppable({
	accept: "span",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
		var oid = elem.id;
		var o=elem.title;
		$myimg=$("span[id='"+oid+"']").siblings("img");
		if($myimg.css("visibility")=="visible"){
		  alert("包含子任务!");
		}
		else{$("span[id='"+oid+"']").parents(".menutitle").parents(".menu").remove();
		   $("div.gghh").children("#ffff:first").children("div.menutitle").attr("id",oid).attr("title",o).children("span").html(o).attr("title",o).attr("id",oid);
           $(this).siblings("div.today").append($("div.gghh").children("#ffff:first").css("display","block"));
           
		}	    
	}
	
});
  });
  
   //span移动 3)
  $(document).ready(function(){
    $("span").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".menu").droppable({
	accept: "span",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
        var parentId=$(this).children("div.menutitle").attr("id"); 
		var oid = elem.id;
		var o=elem.title;
		$myimg=$("span[id='"+oid+"']").siblings("img");
		if($myimg.css("visibility")=="visible"){
		  alert("包含子任务!");
		}
		else{ 
		  $("span[id='"+oid+"']").parents(".menutitle").parents(".menu").remove(); 
		  alert($(this).children(".menutitle").html());
		  $(this).children(".menutitle").children("IMG").attr("visibility","visible");  
		   $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html(o).css("display","block"));                                  
           $.post("task/task_doAjaxUpdateMenuTitleToNav.action",{"task.taskId":oid,"task.task.taskId":parentId},function(data){
           });
		}	    
	}
	
});
  });
   //span移动 4)
  $(document).ready(function(){
    $("span").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".onelist").droppable({
	accept: "span",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
    var typeId=$(this).attr("myid");
        var parentId=$(this).children("div.menutitle").attr("id"); 
		var oid = elem.id;
		var o=elem.title;
		$myimg=$("span[id='"+oid+"']").siblings("img");
		if($myimg.css("visibility")=="visible"){
		  alert("包含子任务!");
		}
		else{
           $("span[id='"+oid+"']").parents(".menutitle").parents(".menu").remove();
            $(this).append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
		$(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	    $.post("task/task_doAjaxUpdateMenuTitleToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
            
		}	    
	}
	
});
  });
  //span移动 5)
  $(document).ready(function(){
    $("span").draggable({
	helper: 'clone',
	opacity: 0.55,
	start:function(e, ui)
    {  
        elem = e.srcElement || e.target;
    }
	});
	
$(".first").droppable({
	accept: "span",
	activeClass: 'droppable-active',
	hoverClass: 'droppable-hover',
	drop: function(ev, ui) 
    {   var taskDate=$("#taskDate").val();
    var typeId=$(this).attr("myid");
        var parentId=$(this).children("div.menutitle").attr("id"); 
		var oid = elem.id;
		var o=elem.title;
		$myimg=$("span[id='"+oid+"']").siblings("img");
		if($myimg.css("visibility")=="visible"){
		  alert("包含子任务!");
		}
		else{
           $("span[id='"+oid+"']").parents(".menutitle").parents(".menu").remove();
            $(this).siblings().append($("div.ffdd").children("#dddd:first").attr("id",oid).attr("title",o).html("<input type='checkbox' class='mynav'>"+o).css("display","block"));
		$(".mynav").bind("click",function(){
	          if($(this).attr('checked')==true){
               $(this).parent().addClass("shanchu");
             }
             else{
               $(this).parent().removeClass("shanchu");
             }
	    });
	      $.post("task/task_doAjaxUpdateMenuTitleToOnelistNav.action",{"date":taskDate,"task.taskId":oid,"task.taskType":typeId},function(data){
         
        });
            
		}	    
	}
	
});
  });
  //添加任务成功提示
    function fade(){
      //停留2秒后消失,在停留的时候,透明度为1.0什么都不做 
          $('<div id="add" class="quick-alert">添加成功！</div>').appendTo("div.leftbg").animate({opacity: 1.0}, 3000).fadeOut("fast",function(){ 
           //隐藏时把元素删除 
          $(this).remove(); 
         }); 
    } 
   //删除任务成功提示
    function fadedel(){
      //停留2秒后消失,在停留的时候,透明度为1.0什么都不做 
          $('<div id="add1" class="quick-alert">删除成功！</div>').appendTo("div.leftbg").animate({opacity: 1.0}, 3000).fadeOut("fast",function(){ 
           //隐藏时把元素删除 
          $(this).remove(); 
         }); 
    }  
  //任务添加
   $(document).ready(function(){
        $("#zhong").val("轻击以添加，回车以继续").css("color","#CCC");
        $("#zhong").focus(function(){
         if($(this).val().replace(" ","")=="轻击以添加，回车以继续"){
           $(this).css("border","1px solid blue"); $(this).val("").css("color","black");
         }
         else{
         $(this).css("border","1px solid blue"); $(this).css("color","black");
         }
        });
         $("#zhong").blur(function(){
           if($(this).val().replace(" ","")==""){
           $(this).css("border","1px solid #CCC"); $(this).val("轻击以添加，回车以继续").css("color","#CCC");
           }
           else{
           $(this).css("border","1px solid #CCC"); $(this).css("color","black");
           }
        });
        $("#zhong").bind("keydown",function(e){
             if(e.which==13){
               var taskName=$(this).val(); 
               var taskDate=$("#taskDate").val();
                $.post("task/task_doAddTask.action",{"task.taskName":taskName},function(data){
                  if(data!=0){
                     $("div.gghh").children("#ffff").children("div.menutitle").attr("id",data).attr("title",taskName).children("span").html(taskName).attr("title",taskName).attr("id",data);
                    var $appendHtml=$("#"+data).parent().css("display","block");
                    $("div.today").prepend($appendHtml);
                    fade();                  
                  }
                  else{
                   alert("添加失败!");
                  }
                });
                 $("#zhong").val("");
             }
        });
   })   
   // 选中删除或者编辑
   $(document).ready(function(){
   $("div.menu").children("div.nav").click(function(){
    $("div.menu").children("div.nav").css("background-color","white");
    $("div.menutitle").css("background-color","white");
     $(this).css("background-color","#DCD6D6");
     var id=$(this).attr("id");$("#delid").val(id);
     $("#input1").show();
     $("#input2").hide();
     $("#input3").show();
     $("#input4").hide();
   })
   
    $("div.menutitle").click(function(){ 
   
     if($(this).siblings("div.nav").length>0){
        $("div.menutitle").css("background-color","white");
       $("div.menu").children("div.nav").css("background-color","white");
       $(this).css("background-color","#DCD6D6");
       var id=$(this).attr("id");$("#delid").val(id);
     $("#input1").show();
     $("#input2").hide();
     $("#input3").show();
     $("#input4").hide();    
     }
     else{
    
       $("div.menutitle").css("background-color","white");
       $("div.menu").children("div.nav").css("background-color","white");
       $(this).css("background-color","#DCD6D6");
       var id=$(this).attr("id");$("#delid").val(id);
     $("#input1").show();
     $("#input2").hide();
     $("#input3").show();
     $("#input4").hide();
     }       
   });
   //删除操作
   $("#input1").click(function(){
      var delId=$("#delid").val();
      if($("#"+delId).attr("class")=="nav"){
        $("#"+delId).remove();
      }
      else{
        $("#"+delId).parent().remove();
      }
      $.post("task/task_doDelTaskById.action",{"task.taskId":delId},function(data){
         if(data=="1"){
          fadedel();
         }
      });
      $("#input2").show();
     $("#input1").hide();
     $("#input4").show();
     $("#input3").hide();
   });
  
  //编辑操作
   $("#input3").click(function(e){
    $('#task_id').css("border","1px solid #CCC");
       var delId=$("#delid").val();
       var taskName="";
       e.preventDefault();	
         $.post("task/task_getTaskById.action",{"task.taskId":delId},function(data){
         $('#task_id').val(data);
       });
		$('#confirm').modal({
		closeHTML:"<a title='Close' class='modal-close' style='cursor:pointer;color:white'>x</a>",
		position: ["20%",],
		overlayId:'confirm-overlay',
		containerId:'confirm-container', 
		onShow: function (dialog) {	
			$('.yes').click(function () {
			var nowText=$('#task_id').val().replace(" ","");
				if((nowText=="")||(nowText==null)){
				 $('#task_id').css("border","2px solid red");return false;
				}
				else{
				  $.post("task/task_updateTaskName.action",{"task.taskName":nowText,"task.taskId":delId},function(data){
				     if(data==1){	
				       if($("#"+delId).attr("class")=="menutitle ui-draggable"){
				               
				          $("#"+delId).children("span").html(nowText).attr("title",o);
				       }
				       else{
				       
				         $("#"+delId).html(nowText);
				       }	       
                       $("#"+delId).attr("title",nowText);                         
				     }
				  })
				}
				$.modal.close();
			});
		}
	});
   });
 })
 
 //今日总结
 $(document).ready(function(){
		  $("#qing").click(function(){
		     $("#mytextarea").val("");
		   $("#filepath").html("");
		   $("#fileList").text("");
		   return false;
		  });
		  
		   $("#queding").click(function(){
		   var filepath="";
		     var mycontent=$("#mytextarea").val();
		     var $files=$("#filepath").children("span");
		     $files.each(function(){
		      filepath=filepath+$(this).html()+";";
		     });

		     $.post("expe/expe_doAddExpe.action",{"expe.experienceContent":mycontent,"expe.filePath":filepath},function(data){
		      if(data=="1"){
		       alert("提交成功!");$("#mytextarea").val("");$("#fileList").text(""); $("#filepath").html("");
		      }
		     });
		     return false;
		   })
		})
		//点击日历查询对应日期的任务
	 var tValue="";       
       $(document).ready(function(){
        setInterval(function(event){
          var nowText=$("#dp-s1").val();
          if(tValue !=nowText){
           $("#center1").hide(); $("#center2").show(); $("#center3").hide();
            var currentDate=new Date(new Date()-1000*60*60*24);
            var selectDate=new Date(nowText.replace(/-/g,"/"));    
           if(selectDate<currentDate){           
            $.post("task/task_getTeakBySmallDate.action",{"date":nowText},function(date){     
               $("#bao1").show();$("#show1").hide();
               //以下是遍历任务并显示 
                   $("#-5").html("");$("#-6").html("");$("#-7").html("");$("#-8").html("");
                    if(date==']'){
                      
                    }
                    else{
                        var data=eval(date);  var tempId=0;var typeId=0;var name="";
                    $.each(data,function(i,v){                      
                      $.each(v,function(k,val){                      
                         if(k=="type"){
                            typeId=val; 
                         }
                         else if(k=="id"){   
                             tempId=val;
                         }
                          else if(k=="name"){   
                             if(typeId==1){
                                   $("#-5").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' checked='checked' disabled='disabled' class='mynav'><font style='text-decoration: line-through'>"+val+"</font>").css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==2){
                                    $("#-6").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' checked='checked' disabled='disabled' class='mynav'><font style='text-decoration: line-through'>"+val+"</font>").css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==3){
                                   $("#-7").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' checked='checked' disabled='disabled' class='mynav'><font style='text-decoration: line-through'>"+val+"</font>").css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==4){
                                    $("#-8").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' checked='checked' disabled='disabled' class='mynav'><font style='text-decoration: line-through'>"+val+"</font>").css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             
                         }                                                 
                      });
                      });                           
                    }
                   
               //以上是遍历任务并显示
               $("#center1").hide(); $("#center2").hide(); $("#center3").show();
           });
           }
           else{         
               $.post("task/task_getTeakByBigDate.action",{"date":nowText},function(date){     
                $("#bao").show();$("#show").hide();
               //以下是遍历任务并显示
                   $("#-1").html("");$("#-2").html("");$("#-3").html("");$("#-4").html("");
                   if(date==']'){
                   
                   }
                   else{
                     var data=eval(date);  var tempId=0;var typeId=0;var name="";    
                    $.each(data,function(i,v){                      
                      $.each(v,function(k,val){                      
                         if(k=="type"){
                            typeId=val; 
                         }
                         else if(k=="id"){   
                             tempId=val;
                         }
                          else if(k=="name"){   
                             if(typeId==1){
                                   $("#-1").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' class='mynav'>"+val).css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==2){
                                    $("#-2").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' class='mynav'>"+val).css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==3){
                                   $("#-3").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' class='mynav'>"+val).css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                             else if(typeId==4){
                                    $("#-4").append($("div.ffdd").children("#dddd:first").attr("id",tempId).attr("title",val).html("<input type='checkbox' class='mynav'>"+val).css("display","block"));
                                   $(".mynav").bind("click",function(){
	                                  if($(this).attr('checked')==true){
                                         $(this).parent().addClass("shanchu");
                                       }
                                     else{
                                        $(this).parent().removeClass("shanchu");
                                         }
	                               });
                             }
                         }                                                 
                      });
                      });                       
                   }
                    
               //以上是遍历任务并显示  
               $("#center1").show(); $("#center2").hide(); $("#center3").hide();
               });
           }
          tValue =nowText;
          $("#taskDate").val(nowText);
        }
       },100);     
      })
       $(document).ready(function(){
       $(".myimg").click(function(){
             if($(this).parent().siblings("div.nav").css("display")=="none"){
             $(this).attr("src","images/xuan1.jpg");
             $(this).parent().siblings("div.nav").css("display","block");
            }
     else{
             $(this).attr("src","images/xuan2.jpg");
            $(this).parent().siblings("div.nav").css("display","none"); 
         }
       });
     }) 
       